﻿@{
    Bundle("jquery_validate");
}

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#form")').validate({
            rules: {
                name: {
                    required: true
                }
            }
        });
        jQuery('@ID("#btn_add_property")').click(function (event) {
            event.preventDefault();
            var propNum = jQuery('@ID("#table_properties") tr').length;
            jQuery('@ID("#table_properties")').append('<tr>' +
                '<td><input type="text" name="properties[' + propNum + '].Key" /></td>' +
                '<td><input type="text" name="properties[' + propNum + '].Value" /></td>' +
                '</tr>');
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Report"))" method="post">
    <table>
        <tr>
            <td>
                <label>@T(Res.Name("Operation"))</label>
            </td>
            <td>
                <input type="text" name="name" />
            </td>
        </tr>
    </table>
    <hr />
    <table id="@ID("table_properties")">
        <tr>
            <td>
                <input type="text" name="properties[0].Key" />
            </td>
            <td>
                <input type="text" name="properties[0].Value" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" name="properties[1].Key" />
            </td>
            <td>
                <input type="text" name="properties[1].Value" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" name="properties[2].Key" />
            </td>
            <td>
                <input type="text" name="properties[2].Value" />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button id="@ID("btn_add_property")" class="button">+</button></li>
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>